home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / s-postim.ads < prev    next >
Text File  |  1994-05-19  |  4KB  |  79 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                    S Y S T E M . P O S I X _ T i m e r s                 --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.2 $                             --
  10. --                                                                          --
  11. --           Copyright (c) 1991,1992,1993, FSU, All Rights Reserved         --
  12. --                                                                          --
  13. --  GNARL is free software; you can redistribute it and/or modify it  under --
  14. --  terms  of  the  GNU  Library General Public License as published by the --
  15. --  Free Software Foundation; either version 2,  or (at  your  option)  any --
  16. --  later  version.   GNARL is distributed in the hope that it will be use- --
  17. --  ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
  18. --  MERCHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. --  eral Library Public License for more details.  You should have received --
  20. --  a  copy of the GNU Library General Public License along with GNARL; see --
  21. --  file COPYING. If not, write to the Free Software Foundation,  675  Mass --
  22. --  Ave, Cambridge, MA 02139, USA.                                          --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. package System.POSIX_Timers is
  27.  
  28.    subtype time_t is Integer range 0 .. Integer'Last;
  29.  
  30.    type Nanoseconds is new Integer;
  31.  
  32.    subtype Fractional_Second is Nanoseconds range 0 .. 10#1#E9 - 1;
  33.    --  This is dependent on the stdtypes.h header file.
  34.  
  35.    type timespec is record
  36.       tv_sec : time_t;
  37.       tv_nsec : Fractional_Second;
  38.    end record;
  39.  
  40.    timespec_First : constant timespec :=
  41.      timespec' (time_t'First, Fractional_Second'First);
  42.  
  43.    timespec_Last : constant timespec :=
  44.      timespec' (time_t'Last, Fractional_Second'Last);
  45.  
  46.    timespec_Zero : constant timespec :=
  47.      timespec' (time_t'First, Fractional_Second'First);
  48.  
  49.    timespec_Unit : constant timespec :=
  50.      timespec' (time_t'First, Fractional_Second'First + 1);
  51.    --  This is dependent on the POSIX.4 implementation; the draft standard
  52.    --  only says that fields of these names and types (with Integer for long)
  53.    --  will be in the record.  There may be other fields, and these do not have
  54.    --  to be in the indicated position.  This should really be done by
  55.    --  getting the sizes and offsets using get_POSIX_Constants and building
  56.    --  the record to match using representation clauses.
  57.  
  58.    --  temporarily, should really only be for 1
  59.    type clock_id_t is private;
  60.  
  61.    CLOCK_REALTIME : constant clock_id_t;
  62.  
  63.    procedure clock_gettime
  64.      (ID     : clock_id_t;
  65.       CT     : out timespec;
  66.       Result : out Integer);
  67.    --  clock_gettime gets POSIX time
  68.    --  (use Return_Code in pthreads)
  69.  
  70. private
  71.  
  72.    type clock_id_t is new Integer;
  73.    --  This clock_id_t is defined as an integer in POSIX
  74.  
  75.    CLOCK_REALTIME : constant clock_id_t := 0;
  76.    --  We currently implement only Realtime clock.
  77.  
  78. end System.POSIX_Timers;
  79.